<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@page contentType="text/html;charset=utf-8" isELIgnored="false" %>
<!DOCTYPE html>
<html lang="zh">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"/>
  <title>修改密码 - 光年(Light Year Admin)后台管理系统模板</title>
  <link rel="icon" href="${base}/favicon.ico" type="image/ico">
  <meta name="keywords" content="LightYear,光年,后台模板,后台管理系统,光年HTML模板">
  <meta name="description" content="LightYear是一个基于Bootstrap v3.3.7的后台管理系统的HTML模板。">
  <meta name="author" content="yinqi">
  <link href="${base}/css/bootstrap.min.css" rel="stylesheet">
  <link href="${base}/css/materialdesignicons.min.css" rel="stylesheet">
  <link href="${base}/css/style.min.css" rel="stylesheet">
  <link href="${base}/css/animate.css" rel="stylesheet">
</head>

<body>


<div class="container-fluid">

  <div class="row">
    <div class="col-lg-12">
      <div class="card">
        <div class="card-body">
          <label style="font-size: 30px">新增帖子类型</label>
          <form method="post" onsubmit="return checkForm()" action="${base}/postType/add" target="mainView" class="site-form">
            <div class="form-group">
              <label for="old-password">帖子类型</label>
              <input type="text" class="form-control" name="type" id="type"
                     placeholder="输入帖子类型">
            </div>
            <a href="${base}/postType/show" target="mainView" class="btn btn-primary">取消</a>
            <button type="submit" class="btn btn-primary">新增</button>
          </form>

        </div>
      </div>
    </div>

  </div>

</div>

<script type="text/javascript" src="${base}/js/jquery.min.js"></script>
<script type="text/javascript" src="${base}/js/bootstrap.min.js"></script>
<script type="text/javascript" src="${base}/js/perfect-scrollbar.min.js"></script>
<script type="text/javascript" src="${base}/js/main.min.js"></script>

<!--消息提示-->
<script  src="${base}/js/bootstrap-notify.min.js"></script>
<script type="text/javascript" src="${base}/js/lightyear.js"></script>
<script type="text/javascript" src="${base}/js/main.min.js"></script>
<script>
  var type;
  var check=true;
  $("#type").blur(function () {
    type=document.getElementById("type").value;
    $.post('${base}/postType/isExit?type='+type,function (a){
      if(a){
        check=false;
        lightyear.loading('show');
        // 假设ajax提交操作
        setTimeout(function() {
          lightyear.loading('hide');
          lightyear.notify('该类型已存在', 'danger', 1000);
        }, 0)
      }else {
        check=true;
      }
    });
  })


  function checkForm() {
    type=document.getElementById("type").value;
    if(!check){
      lightyear.loading('show');
      // 假设ajax提交操作
      setTimeout(function() {
        lightyear.loading('hide');
        lightyear.notify('该类型已存在', 'danger', 1000);
      }, 0)
      return false;
    }

    if(type==""){
      lightyear.loading('show');
      // 假设ajax提交操作
      setTimeout(function() {
        lightyear.loading('hide');
        lightyear.notify('类型不能为空', 'danger', 1000);
      }, 0)
      return false;
    }
  }
</script>

</body>
</html>